package Common.Filters;

public class Filter
{
	private LetterCaseFilter lcf = null;
	private StopWordsFilter swf = null;
	private SymbolFilter sf = null;
	private LengthFilter lf = null;
	private NumberFilter nf = null;
	
	private String ApplyFilters(String word, IFilter[] filters)
	{
		if (word == null)
			return null;
		for(int i=0; i<filters.length; i++)
		{
			word = filters[i].ApplyFilter(word);
			if(word == null)
				break;
		}
		return word;
	}
	
	public String Filtering(String word)
	{
		IFilter[] filters = new IFilter[5];
		if (lcf == null)
			lcf = new LetterCaseFilter();
		if (swf == null)
			swf = new StopWordsFilter();
		if(sf == null)
			sf = new SymbolFilter();
		if(lf == null)
			lf = new LengthFilter();
		//if(nf == null)
		//	nf = new NumberFilter();
		
		filters[0] = lcf;
		filters[1] = sf;
		//filters[2] = nf;
		filters[2] = swf;
		filters[3] = lf;
                filters[4] = swf;
                
                /*
		filters[0] = lcf;
		filters[1] = swf;
		filters[2] = sf;
		filters[3] = lf;
		filters[4] = nf;
		filters[5] = pf;
		filters[6] = lf;
		//filters[2] = pf;
                */
		
		return ApplyFilters(word, filters);
	}
}